package com.ichir.projects.uiflow;

import java.util.HashMap;
import java.util.Map;

import com.ichir.projects.uiflow.ui.api.IUiPart;

/**
 * Application context.
 * 
 * @author mahieddine
 * @since 1.0.0
 */
public class ApplicationContext extends HashMap<String, Object> {

	/**
	 * UID.
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * UI Part event source.
	 */
	private static final String EVENT_UIPART_SOURCE = "uiPartEvebtSource";

	/**
	 * Copy constructor.
	 * @param attributes attributes to copy
	 */
	public ApplicationContext(Map<String, Object> attributes) {
		super(attributes);
	}
	
	/**
	 * Base constructor.
	 */
	public ApplicationContext() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @return event source {@link IUiPart}
	 */
	public IUiPart getEventSource() {
		return (IUiPart) get(EVENT_UIPART_SOURCE);
	}
	
	/**
	 * Set {@link IUiPart} event source.
	 * @param uiPart UI part source to set 
	 */
	public void setEventSource(IUiPart uiPart) {
		put(EVENT_UIPART_SOURCE, uiPart);
	}
	
}
